<?php
if(!defined('IN_PHPSCUP'))exit('hacking'); 
class DefaultApp extends BaseApp
{
    function index()
    {
		if($GLOBALS['SCup']->SCup_user_checking == false)
		{
		$this->login();
		exit;
		}
	    
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', $GLOBALS['Lang']->_get_lang_var(SITE_TITLE));
        $this->assign('page_description', $GLOBALS['Lang']->_get_lang_var(SITE_DESCRIPTION));
        $this->assign('page_keywords', $GLOBALS['Lang']->_get_lang_var(SITE_KEYWORDS));
		
		$this->assign('username',$GLOBALS['SCup']->SCup_user_msg['data']['user_name']);
		        $this->assign('web_view_dir',SITE_URL.'/admin/view/default/');	
        $this->assign('site_url',SITE_URL);		
        $this->assign('leftframe',SITE_URL.'/admin/index.php?app=menu');
        $this->assign('mainframe',SITE_URL.'/admin/index.php?app=default&act=main');
		
        $this->display('index.view.html');
    }

    function main()
    {		
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', $GLOBALS['Lang']->_get_lang_var(SITE_TITLE));
        $this->assign('page_description', $GLOBALS['Lang']->_get_lang_var(SITE_DESCRIPTION));
        $this->assign('page_keywords', $GLOBALS['Lang']->_get_lang_var(SITE_KEYWORDS));

        $this->assign('web_view_dir',SITE_URL.'/admin/view/default/');
        $this->display('main.view.html');
    }

    function login()
    {		
	    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
		header("Cache-Control: no-cache, must-revalidate");
		header("Pragma: no-cache");
		
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', $GLOBALS['Lang']->_get_lang_var(SITE_TITLE));
        $this->assign('page_description', $GLOBALS['Lang']->_get_lang_var(SITE_DESCRIPTION));
        $this->assign('page_keywords', $GLOBALS['Lang']->_get_lang_var(SITE_KEYWORDS));

        $this->assign('web_view_dir',SITE_URL.'/admin/view/default/');	
        $this->display('login.view.html');
    }

    function loginpost()
    {	
		$username = $_POST['username'];		
		$pwd =  $_POST['userpwd'];
		
	    $user = & $GLOBALS['SCup']->_get_user(); 						
	    if($user->login($username,$pwd))
		{
		
          	$notice = &get_message(array('msg'=>'Login Success!','url'=>SITE_URL.'/admin','title'=>'Notice','skip_time'=>500));
	   		$notice ->display();   
		}
		else
		{
		$this->login();
		}
    }

    function quit()
    {		
	   $user = & $GLOBALS['SCup']->_get_user();		
	   if($user->quit())
	   {
	   $GLOBALS['SCup']->SCup_user_checking = false;

	   }
	   else
	   {
	   $notice = &get_message(array('msg'=>'False!','url'=>'','title'=>'Notice'));
	   $notice ->display();	   
	   
	   }
 	   $notice = &get_message(array('msg'=>'Logout Success!','url'=>'?app=default&act=login','title'=>'Notice','skip_time'=>800));
	   $notice ->display();   
    }

    function yzimage()
    {		
      include(ROOT_PATH ."/lib/image.lib.php");
      $string_yzimg=check_rand(4);
      set_cookie("yzImgNum","$string_yzimg", 0,COOKIE_PATH, COOKIE_DOMAIN, false);		  
     // setcookie(COOKIE_PREFIX."yzImgNum","$string_yzimg");
	  $GLOBALS['SCup']->SCup_user_msg['data']['yzImgNum'] = $string_yzimg; 
      Image:: check_img($string_yzimg); 
    }	
	
}
?>